<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body><!-- 法1：直接在标签中加事件响应 -->
		姓名: <input type="text" id="username" onchange="fun1()" /><hr>
		文本框的值被修改为: <span id="res"></span>
		<script type="text/javascript">
			function fun1(){
				let username=document.getElementById("username").value
				let span=document.getElementById("res").innerHTML=username
				console.log(username);
			}
			//法2:为事件属性赋值
			document.body.oncopy=function(){
				console.error("网页禁止复制")
				event.preventDefault()
			}
			//法3:添加事件监听
			let input=document.getElementById("username")
			input.addEventListener("paste",fun2)
			function fun2(){
				console.error("输入框禁止粘贴内容")
				event.preventDefault()
			}
		</script>
	</body>
</html>
